<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01defineProperty方法</title>
</head>
<body>
  <script>
    /* 
    数据描述符独有属性
      value
      writable
    访问器描述符独有属性
      get
      set
    共享属性
      enumerable
      configurable
    */
    let person = {
      name: 'lqj',
      gender: true
    }
    let number = 26
    Object.defineProperty(person, 'addr', {
      value: 'jx',
      writable: true,
      enumerable: true,
      configurable: true
    })
    Object.defineProperty(person, 'age', {
      get(){
        console.log('读取')
        return number
      },
      set(val) {
        console.log('修改')
        number = val
      },
      enumerable: true,
      configurable: true
    })
  </script>
</body>
</html>